```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Spring事件驱动机制详解 | 技术小馆</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            line-height: 1.8;
            color: #333;
            background-color: #f9fafb;
        }
        h1, h2, h3, h4 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 700;
            color: #111827;
        }
        .hero-section {
            background: linear-gradient(135deg, #6b46c1 0%, #805ad5 100%);
        }
        .code-block {
            background-color: #2d3748;
            border-left: 4px solid #805ad5;
        }
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .footer {
            background-color: #1a202c;
        }
        .nav-item:hover {
            color: #805ad5;
        }
        .active-nav {
            color: #805ad5;
            border-bottom: 2px solid #805ad5;
        }
    </style>
</head>
<body class="antialiased">
    <!-- 导航栏 -->
    <nav class="bg-white shadow-sm sticky top-0 z-50">
        <div class="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8">
            <div class="flex justify-between h-16">
                <div class="flex items-center">
                    <span class="text-xl font-bold text-gray-900">技术小馆</span>
                </div>
                <div class="hidden md:flex items-center space-x-8">
                    <a href="#" class="nav-item text-gray-700 hover:text-purple-600 transition-colors duration-300">首页</a>
                    <a href="#" class="nav-item text-gray-700 hover:text-purple-600 transition-colors duration-300">Spring系列</a>
                    <a href="#" class="nav-item active-nav font-medium transition-colors duration-300">事件驱动</a>
                    <a href="#" class="nav-item text-gray-700 hover:text-purple-600 transition-colors duration-300">设计模式</a>
                    <a href="#" class="nav-item text-gray-700 hover:text-purple-600 transition-colors duration-300">关于</a>
                </div>
                <div class="flex items-center md:hidden">
                    <button class="text-gray-500 hover:text-gray-700 focus:outline-none">
                        <i class="fas fa-bars text-xl"></i>
                    </button>
                </div>
            </div>
        </div>
    </nav>

    <!-- Hero Section -->
    <section class="hero-section text-white py-20">
        <div class="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/2 mb-10 md:mb-0">
                    <h1 class="text-4xl md:text-5xl font-bold mb-4 leading-tight">Spring事件驱动机制解析</h1>
                    <p class="text-xl text-purple-100 mb-8">深入理解观察者模式在Spring框架中的实现与应用</p>
                    <div class="flex space-x-4">
                        <button class="bg-white text-purple-700 px-6 py-2 rounded-md font-medium hover:bg-purple-50 transition-colors duration-300">
                            <i class="fas fa-book mr-2"></i>阅读文档
                        </button>
                        <button class="border border-white text-white px-6 py-2 rounded-md font-medium hover:bg-white hover:bg-opacity-10 transition-colors duration-300">
                            <i class="fas fa-code mr-2"></i>查看源码
                        </button>
                    </div>
                </div>
                <div class="md:w-1/2">
                    <div class="mermaid">
                        graph TD
                            A[ApplicationEventPublisher] -->|发布事件| B[ApplicationEventMulticaster]
                            B -->|广播事件| C[ApplicationListener 1]
                            B -->|广播事件| D[ApplicationListener 2]
                            B -->|广播事件| E[ApplicationListener 3]
                            C --> F[处理逻辑]
                            D --> G[处理逻辑]
                            E --> H[处理逻辑]
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- 主要内容 -->
    <main class="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
        <!-- 概述卡片 -->
        <div class="bg-white rounded-xl shadow-md overflow-hidden mb-12 card transition-all duration-300">
            <div class="p-8">
                <div class="flex items-center mb-4">
                    <span class="bg-purple-100 text-purple-800 text-xs font-semibold px-2.5 py-0.5 rounded mr-2">概述</span>
                    <h2 class="text-2xl font-bold">Spring事件驱动机制概述</h2>
                </div>
                <p class="text-gray-700 mb-4">Spring的事件驱动机制基于观察者模式，允许应用程序的不同部分对特定事件作出响应。Spring提供了多种机制来支持事件驱动的编程模型。</p>
                
                <div class="grid md:grid-cols-3 gap-6 mt-6">
                    <div class="border-l-4 border-purple-500 pl-4">
                        <h3 class="font-semibold text-lg mb-2">事件发布者</h3>
                        <p class="text-gray-600">用于发布事件，通常通过ApplicationEventPublisher接口实现</p>
                    </div>
                    <div class="border-l-4 border-purple-500 pl-4">
                        <h3 class="font-semibold text-lg mb-2">事件监听器</h3>
                        <p class="text-gray-600">用于接收和处理特定的事件，可以通过接口或注解实现</p>
                    </div>
                    <div class="border-l-4 border-purple-500 pl-4">
                        <h3 class="font-semibold text-lg mb-2">事件类型</h3>
                        <p class="text-gray-600">通常为ApplicationEvent的子类，可以自定义事件类型</p>
                    </div>
                </div>
            </div>
        </div>

        <!-- 事件发布和监听 -->
        <section class="mb-16">
            <div class="flex items-center mb-8">
                <div class="h-0.5 bg-gray-200 flex-1"></div>
                <h2 class="text-3xl font-bold px-4">事件的发布和监听</h2>
                <div class="h-0.5 bg-gray-200 flex-1"></div>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white rounded-xl shadow-md p-6 card transition-all duration-300">
                    <div class="flex items-center mb-4">
                        <div class="bg-purple-500 text-white p-2 rounded-full mr-3">
                            <i class="fas fa-bullhorn"></i>
                        </div>
                        <h3 class="text-xl font-semibold">事件发布的流程</h3>
                    </div>
                    <p class="text-gray-700 mb-4">当我们发布事件时，通常通过ApplicationEventPublisher来触发事件。ApplicationContext是一个典型的ApplicationEventPublisher的实现类。</p>
                    
                    <div class="code-block rounded-lg overflow-hidden mb-4">
                        <div class="bg-gray-800 text-gray-300 px-4 py-2 text-sm font-mono">
                            <div class="text-purple-400">public class</div> <span class="text-green-400">GenericApplicationContext</span> <span class="text-purple-400">extends</span> <span class="text-green-400">AbstractApplicationContext</span> {
                            <div class="ml-4">
                                <span class="text-purple-400">private final</span> <span class="text-green-400">List</span>&lt;<span class="text-green-400">ApplicationListener</span>&lt;?&gt;&gt; applicationListeners = <span class="text-purple-400">new</span> <span class="text-green-400">ArrayList</span>&lt;&gt;();
                            </div>
                            <div class="ml-4">
                                <span class="text-purple-400">@Override</span>
                            </div>
                            <div class="ml-4">
                                <span class="text-purple-400">public void</span> <span class="text-blue-400">publishEvent</span>(<span class="text-green-400">Object</span> event) {
                                <div class="ml-4">
                                    <span class="text-gray-500">// 发布事件</span>
                                </div>
                                <div class="ml-4">
                                    <span class="text-purple-400">this</span>.<span class="text-blue-400">getApplicationEventMulticaster</span>().<span class="text-blue-400">multicastEvent</span>((<span class="text-green-400">ApplicationEvent</span>) event);
                                </div>
                                }
                            </div>
                            }
                        </div>
                    </div>
                </div>
                
                <div class="bg-white rounded-xl shadow-md p-6 card transition-all duration-300">
                    <div class="flex items-center mb-4">
                        <div class="bg-purple-500 text-white p-2 rounded-full mr-3">
                            <i class="fas fa-headphones"></i>
                        </div>
                        <h3 class="text-xl font-semibold">事件监听器的注册</h3>
                    </div>
                    <p class="text-gray-700 mb-4">事件监听器通过实现ApplicationListener接口或使用@EventListener注解来注册。监听器将会对指定类型的事件做出响应。</p>
                    
                    <div class="code-block rounded-lg overflow-hidden mb-4">
                        <div class="bg-gray-800 text-gray-300 px-4 py-2 text-sm font-mono">
                            <div class="text-purple-400">public class</div> <span class="text-green-400">ApplicationEventMulticaster</span> {
                            <div class="ml-4">
                                <span class="text-purple-400">private final</span> <span class="text-green-400">List</span>&lt;<span class="text-green-400">ApplicationListener</span>&lt;?&gt;&gt; listeners = <span class="text-purple-400">new</span> <span class="text-green-400">ArrayList</span>&lt;&gt;();
                            </div>
                            <div class="ml-4">
                                <span class="text-purple-400">public void</span> <span class="text-blue-400">multicastEvent</span>(<span class="text-green-400">ApplicationEvent</span> event) {
                                <div class="ml-4">
                                    <span class="text-purple-400">for</span> (<span class="text-green-400">ApplicationListener</span>&lt;?&gt; listener : listeners) {
                                    <div class="ml-4">
                                        <span class="text-gray-500">// 根据事件类型，触发监听器处理</span>
                                    </div>
                                    <div class="ml-4">
                                        <span class="text-purple-400">if</span> (listener.<span class="text-blue-400">supportsEventType</span>(event.<span class="text-blue-400">getClass</span>())) {
                                        <div class="ml-4">
                                            listener.<span class="text-blue-400">onApplicationEvent</span>(event);
                                        </div>
                                        }
                                    </div>
                                    }
                                </div>
                                }
                            </div>
                            <div class="ml-4">
                                <span class="text-purple-400">public void</span> <span class="text-blue-400">addApplicationListener</span>(<span class="text-green-400">ApplicationListener</span>&lt;?&gt; listener) {
                                <div class="ml-4">
                                    listeners.<span class="text-blue-400">add</span>(listener);
                                </div>
                                }
                            </div>
                            }
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- 事件的传播过程 -->
        <section class="mb-16">
            <div class="flex items-center mb-8">
                <div class="h-0.5 bg-gray-200 flex-1"></div>
                <h2 class="text-3xl font-bold px-4">事件的传播过程</h2>
                <div class="h-0.5 bg-gray-200 flex-1"></div>
            </div>
            
            <div class="bg-white rounded-xl shadow-md p-8 card transition-all duration-300">
                <div class="flex items-center mb-6">
                    <div class="bg-purple-500 text-white p-2 rounded-full mr-3">
                        <i class="fas fa-network-wired"></i>
                    </div>
                    <h3 class="text-xl font-semibold">事件广播</h3>
                </div>
                <p class="text-gray-700 mb-6">当事件发布时，事件会被传递到ApplicationEventMulticaster中，这里通过遍历监听器列表进行事件广播。</p>
                
                <div class="code-block rounded-lg overflow-hidden mb-6">
                    <div class="bg-gray-800 text-gray-300 px-4 py-2 text-sm font-mono">
                        <div class="text-purple-400">public class</div> <span class="text-green-400">SimpleApplicationEventMulticaster</span> <span class="text-purple-400">extends</span> <span class="text-green-400">AbstractApplicationEventMulticaster</span> {
                        <div class="ml-4">
                            <span class="text-purple-400">@Override</span>
                        </div>
                        <div class="ml-4">
                            <span class="text-purple-400">public void</span> <span class="text-blue-400">multicastEvent</span>(<span class="text-green-400">ApplicationEvent</span> event) {
                            <div class="ml-4">
                                <span class="text-gray-500">// 遍历所有注册的监听器并触发它们</span>
                            </div>
                            <div class="ml-4">
                                <span class="text-purple-400">for</span> (<span class="text-green-400">ApplicationListener</span>&lt;?&gt; listener : <span class="text-blue-400">getApplicationListeners</span>(event)) {
                                <div class="ml-4">
                                    listener.<span class="text-blue-400">onApplicationEvent</span>(event);
                                </div>
                                }
                            </div>
                            }
                        </div>
                        }
                    </div>
                </div>
                
                <div class="bg-purple-50 border-l-4 border-purple-500 p-4">
                    <div class="flex">
                        <div class="flex-shrink-0 text-purple-500">
                            <i class="fas fa-info-circle"></i>
                        </div>
                        <div class="ml-3">
                            <p class="text-sm text-purple-700">
                                SimpleApplicationEventMulticaster遍历所有注册的监听器并触发它们处理事件。事件会在此方法中被多播，所有监听器会依次处理该事件。
                            </p>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- 监听器的执行顺序 -->
        <section class="mb-16">
            <div class="flex items-center mb-8">
                <div class="h-0.5 bg-gray-200 flex-1"></div>
                <h2 class="text-3xl font-bold px-4">监听器的执行顺序</h2>
                <div class="h-0.5 bg-gray-200 flex-1"></div>
            </div>
            
            <div class="bg-white rounded-xl shadow-md p-8 card transition-all duration-300">
                <div class="flex items-center mb-6">
                    <div class="bg-purple-500 text-white p-2 rounded-full mr-3">
                        <i class="fas fa-sort-amount-down"></i>
                    </div>
                    <h3 class="text-xl font-semibold">设置监听器的顺序</h3>
                </div>
                <p class="text-gray-700 mb-6">通过@Order注解或实现PriorityOrdered接口，开发者可以设置监听器的执行顺序。</p>
                
                <div class="code-block rounded-lg overflow-hidden mb-6">
                    <div class="bg-gray-800 text-gray-300 px-4 py-2 text-sm font-mono">
                        <div class="text-purple-400">public class</div> <span class="text-green-400">EventListenerExample</span> {
                        <div class="ml-4">
                            <span class="text-purple-400">@EventListener</span>
                        </div>
                        <div class="ml-4">
                            <span class="text-purple-400">@Order</span>(1)
                        </div>
                        <div class="ml-4">
                            <span class="text-purple-400">public void</span> <span class="text-blue-400">handleFirstEvent</span>(<span class="text-green-400">ApplicationEvent</span> event) {
                            <div class="ml-4">
                                <span class="text-green-400">System</span>.out.<span class="text-blue-400">println</span>(<span class="text-yellow-300">"处理事件顺序：1"</span>);
                            </div>
                            }
                        </div>
                        <div class="ml-4">
                            <span class="text-purple-400">@EventListener</span>
                        </div>
                        <div class="ml-4">
                            <span class="text-purple-400">@Order</span>(2)
                        </div>
                        <div class="ml-4">
                            <span class="text-purple-400">public void</span> <span class="text-blue-400">handleSecondEvent</span>(<span class="text-green-400">ApplicationEvent</span> event) {
                            <div class="ml-4">
                                <span class="text-green-400">System</span>.out.<span class="text-blue-400">println</span>(<span class="text-yellow-300">"处理事件顺序：2"</span>);
                            </div>
                            }
                        </div>
                        }
                    </div>
                </div>
                
                <div class="grid md:grid-cols-2 gap-6">
                    <div>
                        <h4 class="font-semibold mb-2">@Order注解</h4>
                        <p class="text-gray-600">用于设置事件监听器的优先级，数值越小优先级越高</p>
                    </div>
                    <div>
                        <h4 class="font-semibold mb-2">多监听器场景</h4>
                        <p class="text-gray-600">事件会根据优先级依次处理，确保关键监听器先执行</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- 事件监听器的处理 -->
        <section class="mb-16">
            <div class="flex items-center mb-8">
                <div class="h-0.5 bg-gray-200 flex-1"></div>
                <h2 class="text-3xl font-bold px-4">事件监听器的处理</h2>
                <div class="h-0.5 bg-gray-200 flex-1"></div>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white rounded-xl shadow-md p-6 card transition-all duration-300">
                    <div class="flex items-center mb-4">
                        <div class="bg-purple-500 text-white p-2 rounded-full mr-3">
                            <i class="fas fa-code"></i>
                        </div>
                        <h3 class="text-xl font-semibold">实现ApplicationListener接口</h3>
                    </div>
                    
                    <div class="code-block rounded-lg overflow-hidden mb-4">
                        <div class="bg-gray-800 text-gray-300 px-4 py-2 text-sm font-mono">
                            <div class="text-purple-400">public class</div> <span class="text-green-400">CustomEventListener</span> <span class="text-purple-400">implements</span> <span class="text-green-400">ApplicationListener</span>&lt;<span class="text-green-400">MyCustomEvent</span>&gt; {
                            <div class="ml-4">
                                <span class="text-purple-400">@Override</span>
                            </div>
                            <div class="ml-4">
                                <span class="text-purple-400">public void</span> <span class="text-blue-400">onApplicationEvent</span>(<span class="text-green-400">MyCustomEvent</span> event) {
                                <div class="ml-4">
                                    <span class="text-gray-500">// 处理自定义事件</span>
                                </div>
                                <div class="ml-4">
                                    <span class="text-green-400">System</span>.out.<span class="text-blue-400">println</span>(<span class="text-yellow-300">"接收到事件："</span> + event.<span class="text-blue-400">getMessage</span>());
                                </div>
                                }
                            </div>
                            }
                        </div>
                    </div>
                    
                    <div class="mt-4">
                        <h4 class="font-semibold mb-2">特点</h4>
                        <ul class="list-disc pl-5 text-gray-600 space-y-1">
                            <li>通过实现ApplicationListener接口来处理特定类型的事件</li>
                            <li>onApplicationEvent方法会被自动调用来处理事件</li>
                            <li>适用于需要对特定事件类型进行处理的场景</li>
                        </ul>
                    </div>
                </div>
                
                <div class="bg-white rounded-xl shadow-md p-6 card transition-all duration-300">
                    <div class="flex items-center mb-4">
                        <div class="bg-purple-500 text-white p-2 rounded-full mr-3">
                            <i class="fas fa-tags"></i>
                        </div>
                        <h3 class="text-xl font-semibold">使用@EventListener注解</h3>
                    </div>
                    
                    <div class="code-block rounded-lg overflow-hidden mb-4">
                        <div class="bg-gray-800 text-gray-300 px-4 py-2 text-sm font-mono">
                            <div class="text-purple-400">@Component</div>
                            <div class="text-purple-400">public class</div> <span class="text-green-400">EventListenerExample</span> {
                            <div class="ml-4">
                                <span class="text-purple-400">@EventListener</span>
                            </div>
                            <div class="ml-4">
                                <span class="text-purple-400">public void</span> <span class="text-blue-400">handleEvent</span>(<span class="text-green-400">MyCustomEvent</span> event) {
                                <div class="ml-4">
                                    <span class="text-green-400">System</span>.out.<span class="text-blue-400">println</span>(<span class="text-yellow-300">"接收到事件："</span> + event.<span class="text-blue-400">getMessage</span>());
                                </div>
                                }
                            </div>
                            }
                        </div>
                    </div>
                    
                    <div class="mt-4">
                        <h4 class="font-semibold mb-2">特点</h4>
                        <ul class="list-disc pl-5 text-gray-600 space-y-1">
                            <li>使用@EventListener注解标注事件处理方法</li>
                            <li>可以简化事件处理的方式，使代码更具可读性</li>
                            <li>更加灵活，可以处理多种事件类型</li>
                        </ul>
                    </div>
                </div>
            </div>
        </section>

        <!-- 自定义事件的发布和监听 -->
        <section class="mb-16">
            <div class="flex items-center mb-8">
                <div class="h-0.5 bg-gray-200 flex-1"></div>
                <h2 class="text-3xl font-bold px-4">自定义事件的发布和监听</h2>
                <div class="h-0.5 bg-gray-200 flex-1"></div>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white rounded-xl shadow-md p-6 card transition-all duration-300">
                    <div class="flex items-center mb-4">
                        <div class="bg-purple-500 text-white p-2 rounded-full mr-3">
                            <i class="fas fa-plus-circle"></i>
                        </div>
                        <h3 class="text-xl font-semibold">自定义事件的实现</h3>
                    </div>
                    
                    <div class="code-block rounded-lg overflow-hidden mb-4">
                        <div class="bg-gray-800 text-gray-300 px-4 py-2 text-sm font-mono">
                            <div class="text-purple-400">public class</div> <span class="text-green-400">MyCustomEvent</span> <span class="text-purple-400">extends</span> <span class="text-green-400">ApplicationEvent</span> {
                            <div class="ml-4">
                                <span class="text-purple-400">private</span> <span class="text-green-400">String</span> message;
                            </div>
                            <div class="ml-4">
                                <span class="text-purple-400">public</span> <span class="text-blue-400">MyCustomEvent</span>(<span class="text-green-400">Object</span> source, <span class="text-green-400">String</span> message) {
                                <div class="ml-4">
                                    <span class="text-purple-400">super</span>(source);
                                </div>
                                <div class="ml-4">
                                    <span class="text-purple-400">this</span>.message = message;
                                </div>
                                }
                            </div>
                            <div class="ml-4">
                                <span class="text-purple-400">public</span> <span class="text-green-400">String</span> <span class="text-blue-400">getMessage</span>() {
                                <div class="ml-4">
                                    <span class="text-purple-400">return</span> message;
                                </div>
                                }
                            </div>
                            }
                        </div>
                    </div>
                    
                    <div class="mt-4">
                        <h4 class="font-semibold mb-2">要点</h4>
                        <ul class="list-disc pl-5 text-gray-600 space-y-1">
                            <li>自定义事件MyCustomEvent继承自ApplicationEvent</li>
                            <li>包含事件源和事件的附加信息（例如message）</li>
                            <li>可以根据业务需求添加自定义属性和方法</li>
                        </ul>
                    </div>
                </div>
                
                <div class="bg-white rounded-xl shadow-md p-6 card transition-all duration-300">
                    <div class="flex items-center mb-4">
                        <div class="bg-purple-500 text-white p-2 rounded-full mr-3">
                            <i class="fas fa-share-square"></i>
                        </div>
                        <h3 class="text-xl font-semibold">发布自定义事件</h3>
                    </div>
                    
                    <div class="code-block rounded-lg overflow-hidden mb-4">
                        <div class="bg-gray-800 text-gray-300 px-4 py-2 text-sm font-mono">
                            <div class="text-purple-400">public class</div> <span class="text-green-400">CustomEventPublisher</span> {
                            <div class="ml-4">
                                <span class="text-purple-400">private final</span> <span class="text-green-400">ApplicationEventPublisher</span> publisher;
                            </div>
                            <div class="ml-4">
                                <span class="text-purple-400">public</span> <span class="text-blue-400">CustomEventPublisher</span>(<span class="text-green-400">ApplicationEventPublisher</span> publisher) {
                                <div class="ml-4">
                                    <span class="text-purple-400">this</span>.publisher = publisher;
                                </div>
                                }
                            </div>
                            <div class="ml-4">
                                <span class="text-purple-400">public void</span> <span class="text-blue-400">publishEvent</span>(<span class="text-green-400">String</span> message) {
                                <div class="ml-4">
                                    <span class="text-green-400">MyCustomEvent</span> event = <span class="text-purple-400">new</span> <span class="text-blue-400">MyCustomEvent</span>(<span class="text-purple-400">this</span>, message);
                                </div>
                                <div class="ml-4">
                                    publisher.<span class="text-blue-400">publishEvent</span>(event);  <span class="text-gray-500">// 发布事件</span>
                                </div>
                                }
                            </div>
                            }
                        </div>
                    </div>
                    
                    <div class="mt-4">
                        <h4 class="font-semibold mb-2">流程</h4>
                        <ul class="list-disc pl-5 text-gray-600 space-y-1">
                            <li>通过ApplicationEventPublisher发布自定义事件</li>
                            <li>publishEvent方法将事件发布到ApplicationEventMulticaster</li>
                            <li>事件被广播给所有注册的监听器</li>
                        </ul>
                    </div>
                </div>
            </div>
        </section>

        <!-- 事件的异步处理 -->
        <section class="mb-16">
            <div class="flex items-center mb-8">
                <div class="h-0.5 bg-gray-200 flex-1"></div>
                <h2 class="text-3xl font-bold px-4">事件的异步处理</h2>
                <div class="h-0.5 bg-gray-200 flex-1"></div>
            </div>
            
            <div class="bg-white rounded-xl shadow-md p-8 card transition-all duration-300">
                <div class="flex items-center mb-6">
                    <div class="bg-purple-500 text-white p-2 rounded-full mr-3">
                        <i class="fas fa-bolt"></i>
                    </div>
                    <h3 class="text-xl font-semibold">异步事件处理</h3>
                </div>
                <p class="text-gray-700 mb-6">Spring提供了异步事件处理的支持，使得事件的处理不再是同步的，而是能够异步执行，从而提高系统的性能。</p>
                
                <div class="grid md:grid-cols-2 gap-8 mb-8">
                    <div>
                        <h4 class="font-semibold mb-2">启用异步事件处理</h4>
                        <p class="text-gray-600 mb-4">首先需要在Spring配置类上启用异步事件处理。</p>
                        
                        <div class="code-block rounded-lg overflow-hidden">
                            <div class="bg-gray-800 text-gray-300 px-4 py-2 text-sm font-mono">
                                <div class="text-purple-400">@Configuration</div>
                                <div class="text-purple-400">@EnableAsync</div>
                                <div class="text-purple-400">public class</div> <span class="text-green-400">AsyncConfig</span> {
                                <div class="ml-4">
                                </div>
                                }
                            </div>
                        </div>
                    </div>
                    
                    <div>
                        <h4 class="font-semibold mb-2">异步事件监听</h4>
                        <p class="text-gray-600 mb-4">使用@Async注解标注事件处理方法，使其在异步线程中执行。</p>
                        
                        <div class="code-block rounded-lg overflow-hidden">
                            <div class="bg-gray-800 text-gray-300 px-4 py-2 text-sm font-mono">
                                <div class="text-purple-400">@Component</div>
                                <div class="text-purple-400">public class</div> <span class="text-green-400">AsyncEventListener</span> {
                                <div class="ml-4">
                                    <span class="text-purple-400">@EventListener</span>
                                </div>
                                <div class="ml-4">
                                    <span class="text-purple-400">@Async</span>
                                </div>
                                <div class="ml-4">
                                    <span class="text-purple-400">public void</span> <span class="text-blue-400">handleAsyncEvent</span>(<span class="text-green-400">MyCustomEvent</span> event) {
                                    <div class="ml-4">
                                        <span class="text-gray-500">// 异步处理事件</span>
                                    </div>
                                    <div class="ml-4">
                                        <span class="text-green-400">System</span>.out.<span class="text-blue-400">println</span>(<span class="text-yellow-300">"异步处理事件："</span> + event.<span class="text-blue-400">getMessage</span>());
                                    </div>
                                    }
                                </div>
                                }
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="bg-purple-50 border-l-4 border-purple-500 p-4">
                    <div class="flex">
                        <div class="flex-shrink-0 text-purple-500">
                            <i class="fas fa-lightbulb"></i>
                        </div>
                        <div class="ml-3">
                            <h4 class="text-sm font-semibold text-purple-800">异步处理的好处</h4>
                            <ul class="list-disc pl-5 text-sm text-purple-700 mt-1 space-y-1">
                                <li>提高系统响应速度，主线程不会被阻塞</li>
                                <li>可以处理耗时操作而不影响用户体验</li>
                                <li>充分利用多核CPU资源</li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- 总结 -->
        <section class="mb-16">
            <div class="bg-white rounded-xl shadow-md overflow-hidden card transition-all duration-300">
                <div class="p-8">
                    <div class="flex items-center mb-4">
                        <span class="bg-purple-100 text-purple-800 text-xs font-semibold px-2.5 py-0.5 rounded mr-2">总结</span>
                        <h2 class="text-2xl font-bold">Spring事件驱动机制核心要点</h2>
                    </div>
                    
                    <div class="grid md:grid-cols-2 lg:grid-cols-3 gap-6 mt-6">
                        <div class="flex items-start">
                            <div class="bg-purple-100 text-purple-800 p-2 rounded-lg mr-3">
                                <i class="fas fa-project-diagram"></i>
                            </div>
                            <div>
                                <h3 class="font-semibold mb-1">观察者模式实现</h3>
                                <p class="text-gray-600">基于经典的观察者模式，实现松耦合的事件驱动架构</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <div class="bg-purple-100 text-purple-800 p-2 rounded-lg mr-3">
                                <i class="fas fa-exchange-alt"></i>
                            </div>
                            <div>
                                <h3 class="font-semibold mb-1">发布-订阅机制</h3>
                                <p class="text-gray-600">通过事件发布者和监听器实现灵活的发布-订阅机制</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <div class="bg-purple-100 text-purple-800 p-2 rounded-lg mr-3">
                                <i class="fas fa-cubes"></i>
                            </div>
                            <div>
                                <h3 class="font-semibold mb-1">组件解耦</h3>
                                <p class="text-gray-600">有效降低系统组件间的耦合度，提高可维护性</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <div class="bg-purple-100 text-purple-800 p-2 rounded-lg mr-3">
                                <i class="fas fa-sync-alt"></i>
                            </div>
                            <div>
                                <h3 class="font-semibold mb-1">异步处理</h3>
                                <p class="text-gray-600">支持异步事件处理，提升系统性能和响应速度</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <div class="bg-purple-100 text-purple-800 p-2 rounded-lg mr-3">
                                <i class="fas fa-sliders-h"></i>
                            </div>
                            <div>
                                <h3 class="font-semibold mb-1">执行顺序控制</h3>
                                <p class="text-gray-600">通过@Order注解控制监听器执行顺序</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <div class="bg-purple-100 text-purple-800 p-2 rounded-lg mr-3">
                                <i class="fas fa-puzzle-piece"></i>
                            </div>
                            <div>
                                <h3 class="font-semibold mb-1">自定义事件</h3>
                                <p class="text-gray-600">支持自定义事件类型，满足业务特定需求</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <!-- 页脚 -->
    <footer class="footer text-white py-8">
        <div class="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-xl font-bold">技术小馆</h3>
                    <p class="text-gray-400 mt-1">专注Java核心技术分享</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="hover:text-purple-300 transition-colors duration-300">
                        <i class="fas fa-external-link-alt mr-2"></i>http://www.yuque.com/jtostring
                    </a>
                </div>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            fontFamily: "'Noto Sans SC', sans-serif",
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
        
        // 简单的滚动效果
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    </script>
</body>
</html>
```